/*
* 使用匿名内部类创建线程
* */

public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    System.out.println("Hello Thread!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }).start();

        Thread t = new Thread(){
            @Override
            public void run() {
                while(true){
                    System.out.println("Hello Thread!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };

        while(true){
            System.out.println("Hello Thread");
            Thread.sleep(1000);
        }
    }
}
